﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="JsInherit.aspx.cs" Inherits="JsInherit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function Pet(name) {
            this.setName = function (newName) {
                name = newName;
            }

            this.getName = function () {
                return name;
            }

            Pet.prototype.toString = function () {
                return this.getName();
            }
        }

//        var jinmao = new Pet("金毛哈");
        //        alert(jinmao);
        function JinMao(name, weight) {
            Pet.call(this, name);
            //这个很重要


            JinMao.prototype = new Pet();
            JinMao.prototype.constructor = JinMao;
//            JinMao.prototype.toString = function () {
//                return this.getName()+"。这家伙重达:"+weight+"公斤重。。。";
//            }
        }

        var jinmao = new JinMao("金毛哈", 30);

        jinmao.setName("我家的金毛");
        alert(jinmao.toString());

    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
</body>
</html>
